package com.fsj.miniapp.api;

import com.fsj.miniapp.service.GoodsService;
import com.fsj.miniapp.vo.GoodsDetailVo;
import com.fsj.miniapp.vo.GoodsVo;
import com.fsj.miniapp.vo.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shop/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;


    @PostMapping("list")
    public Json goodsList(Long merchantId) {
        List<GoodsVo> goods = goodsService.list(merchantId);

        return Json.succ("goods list").data("data", goods);
    }

    @GetMapping("detail")
    public Json goodsDetail(@RequestParam(name = "id") Long goodsId) {

        GoodsDetailVo goodsDetailVo = goodsService.getDetail(goodsId);

        return Json.succ("goods detail").data("data", goodsDetailVo);
    }

}
